<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<link href="${pageContext.request.contextPath}/assets/js/scrollbar/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />
<script src="${pageContext.request.contextPath}/assets/js/jquery/jquery-1.9.1.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/scrollbar/jquery.mousewheel.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/scrollbar/jquery.mCustomScrollbar.js"></script>
<script type='text/javascript'>
    (function($){
        $(window).load(function(){
            $(".center-left").mCustomScrollbar({
            	theme:"light"
            });
        });
    })(jQuery);
</script>
<div class="center-left" id="center-left">
	<ul class="ul1">
		<c:forEach items="${sessionScope.menu}" var="menu">
			<c:choose>
				<c:when test="${menu.menuId != '' && menu.menuId != null && menu.menuId eq '1' && menu.endFlag != 'yes'}">
					<li style="line-height:30px">
						<h2>
							<img src="${pageContext.request.contextPath}/${menu.iconPath}" style="margin-right:20px;vertical-align:text-bottom;">
							<a href="javascript:void(0);" class="bigmenubase" style="color:#fff;text-align:center;" target="cotentframe">${menu.menuName}</a>
						</h2>
						<ul class="ul2" id="firstul2" style="display:none">
				</c:when>
				<c:when test="${menu.menuId != '' && menu.menuId != null && menu.menuId != '1' && menu.endFlag != 'yes'}">
					<li>
						<h2>
							<img src="${pageContext.request.contextPath}/${menu.iconPath}" style="margin-right:20px;vertical-align:text-bottom;">
							<a href="javascript:void(0);" class="bigmenubase" style="color:#fff" target="cotentframe">${menu.menuName}</a>
						</h2>
						<ul class="ul2" style="display:none">
				</c:when>
				<c:when test="${menu.menuId != '' && menu.menuId != null && menu.endFlag == 'yes'}">
					<li>
						<h2>
							<img src="${pageContext.request.contextPath}/${menu.iconPath}" style="margin-right:20px;vertical-align:text-bottom;">
							<a href="javascript:void(0);" class="bigmenubase" data-href="${pageContext.request.contextPath}/${menu.dataHref}" style="color:#fff" target="cotentframe">${menu.menuName}</a>
						</h2>
						<ul class="ul2" style="display:none">
						</ul>
					</li>
				</c:when>
				<c:when test="${menu.menuId == '' || menu.menuId == null && menu.endFlag != 'yes'}">
					<li><a data-id="${menu.dataId}" data-href="${pageContext.request.contextPath}/${menu.dataHref}" href="javascript:;" target="_self">${menu.menuName}</a></li>
				</c:when>
				<c:when test="${menu.menuId == '' || menu.menuId == null && menu.endFlag eq 'yes'}">
							<li><a data-id="${menu.dataId}" data-href="${pageContext.request.contextPath}/${menu.dataHref}" href="javascript:;" target="_self">${menu.menuName}</a></li>
						</ul>
					</li>
				</c:when>
			</c:choose>
		</c:forEach>
	</ul>
	<script type="text/javascript">
	<!--
		seajs.use(['jquery', 'jquery.cookie'], function($) {
			var merchant_menu_cookie = 'facs_merchant_menu';
			$(function() {
				$(".bigmenubase").click(function(){
					var self = $(this), href = self.data('href');
					var ctx = "${pageContext.request.contextPath}";
					$(this).parent().parent().find('ul').css("visibility","visible");
					$(this).parent().parent().find('ul').removeClass("menu_chioce");
					//if(href==null || href=='' || href=='undefined') {
						$(".menu_chioce").slideUp(); 
					//} 
					$(this).parent().parent().find('ul').slideToggle();
					$(this).parent().parent().find('ul').addClass("menu_chioce");
				});
				
				// 小菜单点击
				$('.ul2 li a').click(function() {
					$.cookie(merchant_menu_cookie, $(this).data('id'), {path: '/' });
					//location.href = $(this).data('href');
					var href = $(this).data('href');
					$(".ul1 li ul a").removeClass("menu-onclick");
					$(this).addClass("menu-onclick");
					$("#cotentframe").attr("src",href);
				});
				
				// 大菜单点击
				$('.ul1 li h2 a').click(function() {
					var self = $(this), href = self.data('href');
					if(href!=null && href!='' && href!='undefined' && href!='/ibms-web/') {
						$(".ul1 li ul a").removeClass("menu-onclick");
						$("#cotentframe").attr("src",href);
					} else {
						return false;
					}
				});
				
				if ($.cookie) {
					var ctx = "${pageContext.request.contextPath}";
					var menu = $.cookie(merchant_menu_cookie), path = $.trim(location.href);
					if(menu == ''|| menu == undefined || menu == null) {
						$('#firstul2').slideToggle();
						$('#firstul2').css("display","block");
						$('#firstul2').addClass("menu_chioce");
						$('#firstul2 li a').addClass("menu-onclick");
					}
					$('.ul1 li ul a').each(function(i, ele) {
						var self = $(this), id = self.data('id');
						
						if (menu == undefined && path.indexOf(id) != -1) {
							self.css('color', '#5b6372').parent().addClass('menu-selected');
							return false;
						} else {
							if (path.indexOf(id) != -1 || menu == id) {
								self.parent().parent('.ul2').slideToggle();
								self.parent().parent('.ul2').css("display","block");
								self.parent().parent('.ul2').addClass("menu_chioce");
								self.css('color', '#5b6372').parent().addClass('menu-selected');
								return false;
							}
						}
					});
				}
			});
		});
	//-->
	</script>
</div>